package com.br.estoque.model.mvc.controller;

import java.io.IOException;
import java.util.HashMap;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ServletController extends HttpServlet {
	HashMap<String, ICommand> map;
	
	public ServletController() {
		map = new HashMap<String, ICommand>();
		map.put("criarMaterial", new CriarMaterial()) ;
	}
	protected void  service(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException{

		String action = request.getParameter("action");
		ICommand command = map.get(action);
		
		if(command != null){
			command.execute(request, response);
			return;
		}
		response.getWriter().print("<html<body><b1>Tentativa indireta de acesso</b1></body></html>");
	}
	
}
